﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Net.Chirash.Twitter.TwitterClient;
using Net.Chirash.Twitter.TweetZone.WindowComponents.ViewModels;

namespace Net.Chirash.Twitter.TweetZone.WindowComponents.Containers
{
    /// <summary>
    /// SearchContainer.xaml の相互作用ロジック
    /// </summary>
    public partial class SearchContainer : Container
    {
        #region Constructors

        public SearchContainer()
            : this(new SearchContainerViewModel())
        {
        }

        public SearchContainer(SearchContainerViewModel viewmodel)
            : base(viewmodel)
        {
            InitializeComponent();
            HashtagTextBox.Text = DefaultHashtagText;
        }

        #endregion

        #region Private Events

        private void HashtagTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (HashtagTextBox.Text == "" || HashtagTextBox.Text == DefaultHashtagText)
            {
                return;
            }
            ViewModel.Refresh();
        }

        private void HashtagTextBox_GotFocus(object sender, RoutedEventArgs e)
        {
            if (HashtagTextBox.Text == DefaultHashtagText)
            {
                HashtagTextBox.Text = "";
            }
        }

        private void HashtagTextBox_LostFocus(object sender, RoutedEventArgs e)
        {
            if (HashtagTextBox.Text == "")
            {
                HashtagTextBox.Text = DefaultHashtagText;
            }
        }

        #endregion

        #region Private Fields

        private const string DefaultHashtagText = "Input hashtags here";

        #endregion

    }
}
